package com.cy.pj.module.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class ModuleController {//代表任意一个模块Controller,其中Module的含义为模块
    @RequestMapping("doCompute/{n1}/{n2}")
    @ResponseBody
    public String doCompute(@PathVariable Integer n1,@PathVariable Integer n2){
        //try {
            Integer result=n1/n2;
            return "resule is "+result;
        //}catch (java.lang.ArithmeticException e){
            //log.info("exception {}",e.getMessage());
            //return "除数不能为0";
        //}
    }
    /*
    //ExceptionHandler注解描述的方法为spring web模板中的异常处理方法
    @ExceptionHandler(ArithmeticException.class)
    @ResponseBody
    public String doHandleArithmeticException(ArithmeticException e){
        e.printStackTrace();
        System.out.println("ModuleController.doHandleArithmeticException()");
        return "计算过程中出现异常，异常信息为"+e.getMessage();
    }
    */
}
